package com.huiyeji.hui.vo;

import com.huiyeji.hui.service.ApplicationService;

import java.time.LocalDateTime;

/**
 * @author zhaoduo
 */
public class MessageVo {

    private Long sender;
    private Long receiver;
    private String content;
    private LocalDateTime createTime;
    private Type type;

    public enum Type{

        /**
         * 群聊消息
         */
        GROUP_MSG {
            @Override
            public void send(ApplicationService service, MessageVo vo) {
                service.sendGroupMsg(vo);
            }
        },

        /**
         * 私聊消息
         */
        PRIVATE_MSG{
            @Override
            public void send(ApplicationService service,MessageVo vo) {
                service.sendPrivateMsg(vo);
            }
        },

        /**
         * 群聊邀请
         */
        GROUP_INVITATION {
            @Override
            public void send(ApplicationService service,MessageVo vo) {
                service.sendGroupInvitation(vo);
            }
        },

        /**
         * 好友申请
         */
        FRIEND_INVITATION {
            @Override
            public void send(ApplicationService service,MessageVo vo) {
                service.sendFriendInvitation(vo);
            }
        },

        /**
         * 邀请同意回复
         */
        AGREE_INVITATION{
            @Override
            public void send(ApplicationService service, MessageVo vo) {
                throw new UnsupportedOperationException();
            }
        },

        /**
         * 拒绝邀请回复
         */
        REFUSE_INVITATION{
            @Override
            public void send(ApplicationService service, MessageVo vo) {
                throw new UnsupportedOperationException();
            }
        },

        /**
         * 出错回复
         */
        ERROR {
            @Override
            public void send(ApplicationService service, MessageVo vo) {
                throw new UnsupportedOperationException();
            }
        },

        /**
         * 下线通知
         */
        ONLINE_NOTICE{
            @Override
            public void send(ApplicationService service, MessageVo vo) {
                throw new UnsupportedOperationException();
            }
        },

        /**
         * 上线通知
         */
        OFFLINE_NOTICE{
            @Override
            public void send(ApplicationService service, MessageVo vo) {
                throw new UnsupportedOperationException();
            }
        },

        /**
         * 群聊删除某成员通知
         */
        GROUP_KICK_OUT{
            @Override
            public void send(ApplicationService service, MessageVo vo) {
                throw new UnsupportedOperationException();
            }
        },

        /**
         * 群聊解散通知
         */
        GROUP_REMOVE{
            @Override
            public void send(ApplicationService service, MessageVo vo) {
                throw new UnsupportedOperationException();
            }
        },

        /**
         * 删除好友通知
         */
        DELETE_FRIEND {
            @Override
            public void send(ApplicationService service, MessageVo vo) {
                throw new UnsupportedOperationException();
            }
        };

        public abstract void send(ApplicationService service,MessageVo vo);

    }

    public MessageVo() {
    }

    public MessageVo(Long sender, Long receiver, String content, LocalDateTime createTime, Type type) {
        this.sender = sender;
        this.receiver = receiver;
        this.content = content;
        this.createTime = createTime;
        this.type = type;
    }


    public LocalDateTime getCreateTime() {
        return createTime;
    }

    public void setCreateTime(LocalDateTime createTime) {
        this.createTime = createTime;
    }

    public Long getSender() {
        return sender;
    }

    public void setSender(Long sender) {
        this.sender = sender;
    }

    public Long getReceiver() {
        return receiver;
    }

    public void setReceiver(Long receiver) {
        this.receiver = receiver;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public Type getType() {
        return type;
    }

    public void setType(Type type) {
        this.type = type;
    }
}
